package tron.common;

import lombok.Data;

/**
 * 全局统一返回值
 * @param <T>
 */
@Data
public  class ApiResult <T>{
    private Integer state;
    private String message;
    private T data;

    public static <T> ApiResult<T> success(T t) {
        ApiResult<T> apiResult = new ApiResult<>();
        apiResult.state = 200;
        apiResult.message = "success";
        apiResult.data = t;
        return apiResult;
    }

    public static <T> ApiResult<T> fail(String message) {
        ApiResult<T> apiResult = new ApiResult<>();
        apiResult.state = 500;
        apiResult.message = message;
        apiResult.data = null;
        return apiResult;
    }
}
